/*

	Texture.h
	
	Header file for the Texture class. This
	class stores pixel data and format for 
	textures and can be used for drawing sprites
	or texturing meshes.
	
	Written by Sigurd Suhm 2009

*/

#ifndef _TEXTURE_H
#define _TEXTURE_H

// Includes
#include <SDL/SDL.h>	// SDL header
#include <SDL/SDL_opengl.h>		// OpenGL header

namespace EraAstral
{
	namespace graphics
	{	
		// Texture class
		class Texture
		{
			private:
				// Pointer to array of pixel data
				void *m_data;
				// Indicates if the data stores an alpha component
				bool m_hasAlpha;
				// Texture dimensions
				unsigned int m_width, m_height;
				// Format of the pixel data
				GLenum m_format;
				// OpenGL index of the texture
				GLuint m_glIndex;
				
			public:
				// Default constructor
				Texture();
				// Constructor creating a texture from an SDL surface
				Texture(const SDL_Surface *surface);
				// Default destructor
				~Texture();
				
				// Commits the texture to OpenGL and returns the index
				//  of the texture
				GLuint 	Commit();
				// Binds the texture so OpenGL can use it for texturing
				void	Bind();
				
				// Accessors
				void 		*GetPixelData() const;		// Returns a pointer to the pixel data
				unsigned int	GetWidth();			// Get texture width
				unsigned int	GetHeight();			// Get texture height
				GLenum 		GetFormat();			// Get pixel format
		};
	}
}

#endif		// _TEXTURE_H
